package com.study.concurrent.B_ThreadSynchronizedBasic.f_UseReadWriteLock;

/**
 * Created by 赵超 on 2017/3/23.
 */
public class Reader implements Runnable {
    private PricesInfo pricesInfo;

    public Reader(PricesInfo pricesInfo) {
        this.pricesInfo = pricesInfo;
    }

    /**
     * 读取两个价格10次
     */
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.printf("%s : Price 1 : %f\n",
                    Thread.currentThread().getName(), pricesInfo.getPrice1());
            System.out.printf("%s : Price 2 : %f\n",
                    Thread.currentThread().getName(), pricesInfo.getPrice2());
        }
    }
}
